<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>微信活动管理</title>
    <%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<meta name="decorator" content="default"/>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="3fb87e2c1935452691928c7202ee270f" />
    <div class="page-content">
        <form:form id="searchForm" modelAttribute="huodongEntity" action="${ctx}/wechat/huodongEntity/" method="post">
            <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
            <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
        </form:form>
        <table id="contentTable" class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th colspan="2">活动名称</th>
                    <th>参与人数</th>
                    <th>活动总成本</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th colspan="3">活动描述</th>
                    <shiro:hasPermission name="wechat:huodongEntity:edit">
                        <th>操作</th>
                    </shiro:hasPermission>
                </tr>
            </thead>
            <tbody>
            <c:forEach items="${list}" var="huodongEntity">
                <tr id="${huodongEntity.id}" pId="0">
                    <td colspan="2"><a href="javascript:;" onclick="treeTableTrtoggle('${huodongEntity.id}');">${huodongEntity.title}</a></td>
                    <td></td>
                    <td></td>
                    <td><fmt:formatDate value="${huodongEntity.starttime}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                    <td><fmt:formatDate value="${huodongEntity.endtime}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                    <td colspan="3">${huodongEntity.description}</td>
                    <shiro:hasPermission name="wechat:huodongEntity:edit"><td>
                        <a href="${ctx}/wechat/huodongEntity/form?id=${huodongEntity.id}">修改</a>
                        <a href="javascript:;" onclick="deleteMsg('确认要删除该文本消息模板吗？','${ctx}/wechat/huodongEntity/delete?id=${huodongEntity.id}',this);">删除</a>
                    </td></shiro:hasPermission>
                </tr>
                <c:if test="${not empty huodongEntity.prizeList}">
                    <tr id="-1" pId="${huodongEntity.id}">
                        <th>奖品名称</th>
                        <th>奖品总数</th>
                        <th>已用</th>
                        <th>价格</th>
                        <th>概率1</th>
                        <th>概率2</th>
                        <th>概率3</th>
                        <th>状态</th>
                        <th>等级</th>
                        <th>排序</th>
                    </tr>
                    <c:forEach items="${huodongEntity.prizeList}" var="prize">
                        <tr id="${prize.id}" pId="${huodongEntity.id}">
                            <td>${prize.name}</td>
                            <td>${prize.totalnum}</td>
                            <td>${prize.usenum}</td>
                            <td>${prize.price}</td>
                            <td>${prize.rate1}</td>
                            <td>${prize.rate2}</td>
                            <td>${prize.rate3}</td>
                            <td>${prize.status eq '0'?'有效':'无效'}</td>
                            <td>
                                <c:choose>
                                    <c:when test="${prize.level eq '1'}">一等奖</c:when>
                                    <c:when test="${prize.level eq '2'}">二等奖</c:when>
                                    <c:when test="${prize.level eq '3'}">三等奖</c:when>
                                    <c:when test="${prize.level eq '4'}">四等奖</c:when>
                                    <c:when test="${prize.level eq '5'}">五等奖</c:when>
                                </c:choose>
                            </td>
                            <td>${prize.sort}</td>
                        </tr>
                    </c:forEach>
                </c:if>
            </c:forEach>
            </tbody>
        </table>
        <div class="pagination">${page}</div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $("#contentTable").treeTable({expandLevel : 1});
    });

    //删除
    function deleteMsg(msg,href,tr){
        bootbox.confirm(msg,function(obj){
            if(obj) {
                $.post(href,function(data){
                    if(data.success){
                        showNote("success", function () {
                            $(tr).parent().parent().remove();
                        }, data.msg, "center");
                    }else {
                        showNote("error", function () {
                            return false;
                        }, data.msg);
                    }
                });
            }
        });
    }

    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
</body>
</html>
